using Game.Const;
using Game.Core;
using Game.Main.Model;
using Game.Manager;
using UnityEngine;

namespace Game.Component
{
	public class WashingMachineItem : ContainerItem
	{
		public override void Init(ItemArchiveData data)
		{
			base.Init(data);
		}

		public override void ResetState()
		{
			base.ResetState();
			CheckIsWashing();
		}

		protected override void LateUpdate()
		{
			if (anim == Anim.Static)
			{
				return;
			}
			base.LateUpdate();
			if (anim == Anim.Static && childItems.Count > 0)
			{
				if (state == State.Open)
				{
					Singleton<AudioManager>.Instance.PlaySound("sound_blink");
					Singleton<EffectManager>.Instance.ShowEffect(PathConst.EFFECT + "efc_blink_1", base.transform.position + new Vector3(0f, -2.4f, -0.0004f), 3f);
					StopDragEffect();
					RemoveAudioPlayer();
				}
				else if (state == State.Close)
				{
					CheckIsWashing();
				}
			}
		}

		private void CheckIsWashing()
		{
			if (childItems.Count > 0 && state == State.Close)
			{
				PlayDragEffect(0f);
				Singleton<AudioManager>.Instance.PlayAudio("sound_washing_machine", true, GetAudioPlayer());
			}
			else
			{
				StopDragEffect();
				RemoveAudioPlayer();
			}
		}
	}
}
